package com.kordar.api.modular.unicomJS;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;

@Data
public class ZOPChoiceNumberRequestImpl implements Request {

    @NotEmpty(message = "{zop.provinceCode}{javax.validation.constraints.NotEmpty.message}")
    @Length(max = 2, min = 2, message = "{zop.provinceCode.size}")
    private String provinceCode;

    @NotEmpty(message = "{zop.cityCode}{javax.validation.constraints.NotEmpty.message}")
    @Size(max = 3, min = 3, message = "{zop.cityCode.size}")
    private String cityCode;

    @NotEmpty(message = "{zop.goodsId}{javax.validation.constraints.NotEmpty.message}")
    private String goodsId;

    @NotEmpty(message = "{zop.qryType}{javax.validation.constraints.NotEmpty.message}")
    private String qryType = "02";

    @NotEmpty(message = "{zop.searchCategory}{javax.validation.constraints.NotEmpty.message}")
    private String searchCategory = "1";

    private String searchType;
    private String searchValue;
    private String amounts;

    /**
     * provinceCode	body	是	String		号码归属省分编码(3位)
     * cityCode	body	是	String		号码归属地市编码(2位)
     * goodsId	body	是	String		商品ID
     * qryType	body	是	String		查询类型：02：
     * searchCategory	body	是	String		查询类型: 1 普通选号
     * searchType	body	否	String		尾号查询02 匹配最后四位
     * searchValue	body	否	String		尾号查询关键字：2-4位数字（和searchType配对出现，searchType有值的话，searchValue不可为空）
     * amounts	body	否	String		返回号码数 支持10 100 ，不填默认100
     *
     * @return JSONObject
     */
    @Override
    public JSONObject body() {
        JSONObject object = new JSONObject();
        object.put("provinceCode", provinceCode);
        object.put("cityCode", cityCode);
        object.put("goodsId", goodsId);
        object.put("qryType", qryType);
        object.put("searchCategory", searchCategory);
        object.put("searchType", searchType);
        object.put("searchValue", searchValue);
        object.put("amounts", amounts);
        return object;
    }

    @Override
    public String url() {
        return "http://58.240.52.214:80/jszop/zop_link/number?secretKey=" + SysParams.SYS_SECRET_KEY.getName();
    }
}
